package com.dou.you.che.comm.utils.response;

import java.util.HashMap;
import java.util.Map;

/**
 * 结果输出<Rest 返回输出></>
 * @Author 黄国刚【1058118328@qq.com】
 */
public class RspData extends HashMap<String, Object> {

    private static final long serialVersionUID = 1L;

    public RspData() {
        put("code", 0);
    }

    public static RspData error() {
        return error(500, "系统发生错误，请重试或联系管理员解决！");
    }

    public static RspData error(String msg) {
        return error(500, msg);
    }

    public static RspData error(int code, String msg) {
        RspData r = new RspData();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static RspData ok(String msg) {
        RspData r = new RspData();
        r.put("msg", msg);
        return r;
    }

    public static RspData ok(Map<String, Object> map) {
        RspData r = new RspData();
        r.putAll(map);
        return r;
    }

    public static RspData ok() {
        return new RspData();
    }

    @Override
    public RspData put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
